
/*----------------------------------------------------------------------
  File Name          : OpenImu.h
  Author             : Neil Zhang - Gu
  Version            : V1.0
  Date               : 30/3/2020
  Description        : OpenImu Registers Address

  Analog Devices OpenImu is a complete triple axis gyroscope
  and triple axis accelerometer inertial sensing system

  China Applications Support Team.
  china.support@analog.com
----------------------------------------------------------------------

----------------------------------------------------------------------*/
#ifndef _WingbowHost_H_
#define _WingbowHost_H_

#ifdef __cplusplus
extern "C"
{
#endif
    
#include "stm32f10x.h"
#include "delay.h"
#include "usart.h"
#include "encoder.h"
#include "OpenImu.h"
#include "string.h"
#include "stmflash.h"
#include "usart3.h"

    
enum  HostOrder{
  CalibrationEncoderZero = 0x01,  
  CalibrationUltrasound  = 0x02,
  CalibrationEncoderAngle = 0x03, 
  GetImuAngleVel          =0x04
};

typedef struct {
  u8 FrameLength;
  u8 ReturnData[30];
  float Height[4];
}HostData ;


extern OpenImu *openImu;

    
class WingbowHost
{
  private:
      UartRecv *HostEvent;
      Queue *HostQueue;
      HostData WingbowData;
  public:
      static WingbowHost *get(void);
      bool init(void);
      u8 AnalyWingbowHost();      //解析上位机发下来的指令
      u8 HandleEncoderZero (Queue *queue);
      u8 HandleEncoderAngle(Queue *queue);
      u8 HandleUltrasound (Queue *queue);
      u8 HandleImuAngleVel(Queue *queue);
      u8 GetFlashHeight();
      u8 ReturnHost(u8 order);
      u8 ReturnF4(u8 order);
      void (*uartsend)(u8 *,u8);           //定义一个函数指针,指向串口发送数据函数
      void (*uartCrc)(u8 *);           //定义一个函数指针,指向串口CRC校验
      int CaculateCRC(u8 *queue, u8 framelength);   //计算CRC
  public:
      
  private:
      WingbowHost();

};

extern WingbowHost *wingbowHost;

#ifdef __cplusplus
}
#endif

#endif
